<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <!-- <script src="http://localhost:8080"></script> -->
    <!-- 引入react核心库 -->
    <script type="text/javascript" src="../../js/react.development.js"></script>
    <!-- 用于支持react操作DOM -->
    <script type="text/javascript" src="../../js/react-dom.development.js"></script>
    <!-- 用于将jsx转为js -->
    <script type="text/javascript" src="../../js/babel.min.js"></script>
</head>
<body>
    <div id="test"></div>

    <script type="text/babel">
        class MyComponent extends React.Component{
            state = {on: true}
            render() {
                return (
                    <h2 onClick={this.change}>状态{this.state.on ? 0 : 1}</h2>
                )
            }
            // 自定义的方法，用箭头函数
            change = () => {
                this.setState({on: !this.state.on})
            }
        }
        ReactDOM.render(<MyComponent/>,document.getElementById("test"))
    </script>
</body>
<style>
</style>
</html>